package cn.com.bluemoon.daps.api.model.factory;

import cn.com.bluemoon.daps.api.model.RemoteModeUserAccreditService;
import cn.com.bluemoon.daps.common.constant.ServiceNameConstants;
import cn.com.bluemoon.daps.common.domain.ResultBean;
import cn.com.bluemoon.daps.common.toolkit.FeignClientTools;
import cn.com.bluemoon.daps.model.entity.DapDataModelUserAccredit;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;
import java.util.Map;

/**
 * 熔断
 *
 * @author Jarod.Kong
 * @date 2021/3/29 16:51
 */
public class RemoteModeUserAccreditServiceFactory implements FallbackFactory<RemoteModeUserAccreditService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteHandlerStdRelateServiceFallbackFactory.class);

    @Override
    public RemoteModeUserAccreditService create(Throwable throwable) {
        log.error("用户模型授权信息服务调用失败:{}", throwable.getMessage());
        return new RemoteModeUserAccreditService() {
            @Override
            public ResultBean<Map<String, List<DapDataModelUserAccredit>>> listByModel() {
                return FeignClientTools.INSTANCE.errorMsgCatch(throwable, ServiceNameConstants.DapsApiModel.PROD_SERVICE, "获取模型用户授权信息");
            }
        };
    }
}